package osx.mantianx.dao.lmpl;

import org.mybatis.spring.support.SqlSessionDaoSupport;
import osx.mantianx.dao.UserMapper;
import osx.mantianx.pojo.User;

import java.util.concurrent.CopyOnWriteArrayList;

/**
 * @author starrysky
 * @title: UserMapperImpl
 * @projectName spring5_Transaction
 * @description: TODO
 * @date 2021/2/323:01
 */
public class UserMapperImpl extends SqlSessionDaoSupport implements UserMapper {

    @Override
    public CopyOnWriteArrayList<User> selectUser() {
        User user = new User(7777L, "sss", "fdfdf");
        UserMapper mapper = getSqlSession().getMapper(UserMapper.class);
        mapper.insertUser(user);
        mapper.deleteUser(2L);
        return mapper.selectUser();
    }

    @Override
    public int insertUser(User user) {
        return getSqlSession().getMapper(UserMapper.class).insertUser(user);

    }

    @Override
    public int deleteUser(Long id) {
        return getSqlSession().getMapper(UserMapper.class).deleteUser(id);
    }

}
